# Apache Web服务器 ***Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.*** --- Apache Web服务器(Apache HTTP Server)是一款由Apache软件基金会开发和维护的开源、跨平台Web服务器软件。它以稳定、安全和高度可扩展著称,支持通过丰富的模块实现多种功能,是全球最广泛使用的Web服务器之一,常用于网站托管、动态应用支持以及反向代理等场景。 本文档介绍了如何在Debian/Linux上安装并运行 **Apache Web服务器**。 # 准备工作 1. 确认设备环境; - 设备可正常联网 - Windows主机和设备处于同一局域网内 2. 检查网络连通。 - 在终端执行 *ping www.baidu.com*,若能看到返回的时间信息,则说明网络正常。 # 安装Apache Web服务 Apache是最常用的网页服务器程序之一,用于提供网站访问服务。 1. 更新软件源: ```plaintext sudo apt update ``` 2. 安装Apache服务: ```plaintext sudo apt install apache2 -y ``` # 启动与设置自动启动 1. 启动Apache服务: ```plaintext sudo systemctl start apache2 ``` > 启动Web服务,使其立即运行。 2. 设置为开机自动启动: ```plaintext sudo systemctl enable apache2 ``` > 设置后,系统每次开机都会自动启动Apache。 3. 查看运行状态: ```plaintext sudo systemctl status apache2 ``` # 查看设备IP地址 ```plaintext sudo ifconfig ``` # 测试Apache是否安装成功 1. 在同一局域网内的电脑浏览器中访问: ```plaintext http://你的ip地址 ``` 如果一切正常,将会看到Apache的默认页面。 ```{image} images/image_Fq16b46nPo9Dy3xyarJcoEcon9i.webp :width: 827px :height: 947px ``` # 更改默认网页 Apache的默认网页是文件系统中的一个HTML文件,位于 */var/www/html/index.html*。 导航到此目录并查看内容: ```plaintext cd /var/www/html ls -al ``` 将会展示以下内容: ```plaintext total 20 drwxr-xr-x 2 root root 4096 Oct 30 07:53 . drwxr-xr-x 3 root root 4096 Oct 30 06:51 .. -rw-r--r-- 1 root root 10703 Oct 30 06:51 index.html ``` 系统默认在 */var/www/html* 目录下存在一个名为 *index.html* 的网页文件,其所有者为 *root* 用户。由于普通用户无权直接修改root所属的文件,若需编辑该网页,需将其所有者改为您自己的用户名。 ```plaintext sudo chown : index.html ``` 现在您可以编辑该文件。修改完成后,只需刷新浏览器,即可查看网页的变化。 如果您熟悉HTML,也可以将自己的HTML文件和其他资源放到此目录中,并通过本地网络将它们作为网站进行访问。